package com.medvalley.tcm.controller;

import com.medvalley.tcm.base.Result;
import com.medvalley.tcm.domain.*;
import com.medvalley.tcm.service.YangShengService;
import com.medvalley.tcm.vo.inputvo.SportsInputVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

@Api(value = "养生建议接口")
@RestController
@RequestMapping("/yangsheng")
public class YangShengController extends BaseController {

    @Autowired
    private YangShengService yangShengService;

    @ApiOperation(value = "保存针灸数据")
    @RequestMapping(value = "/acupuncture/add", method = RequestMethod.POST)
    public Result addAcupuncture(@ModelAttribute YangShengAcupuncture yangShengAcupuncture) {
        yangShengService.saveYangShengAcupuncture(yangShengAcupuncture);
        return success("保存成功", yangShengAcupuncture);
    }

    @ApiOperation(value = "根据id获取针灸数据")
    @RequestMapping(value = "/acupuncture/get", method = RequestMethod.POST)
    public Result getAcupuncture(@RequestParam long id) {
        YangShengAcupuncture yangShengAcupuncture = yangShengService.getYangShengAcupunctureById(id);
        return success("", yangShengAcupuncture);
    }

    @ApiOperation(value = "根据名字获取针灸数据")
    @RequestMapping(value = "/acupuncture/getByName", method = RequestMethod.POST)
    public Result getAcupuncture(@RequestParam String name) {
        YangShengAcupuncture yangShengAcupuncture = yangShengService.getYangShengAcupunctureByName(name);
        return success("", yangShengAcupuncture);
    }

    @ApiOperation(value = "更新针灸数据")
    @RequestMapping(value = "/acupuncture/update", method = RequestMethod.POST)
    public Result updateAcupuncture(@ModelAttribute YangShengAcupuncture yangShengAcupuncture) {
        yangShengService.updateYangShengAcupuncture(yangShengAcupuncture);
        return success("更新成功", yangShengAcupuncture);
    }

    @ApiOperation(value = "翻页获取艾灸建议列表")
    @RequestMapping(value = "/acupuncture/page", method = RequestMethod.POST)
    public Result pageAcupuncture(@RequestParam int pageNo, @RequestParam int pageSize) {
        Page<YangShengAcupuncture> result = yangShengService.pageYangShengAcupuncture(pageNo, pageSize);
        return success(result);
    }

    @ApiOperation(value = "删除针灸数据")
    @RequestMapping(value = "/acupuncture/delete", method = RequestMethod.POST)
    public Result deleteAcupuncture(@RequestParam long id) {
        yangShengService.deleteYangShengAcupuncture(id);
        return success("删除成功");
    }


    @ApiOperation(value = "保存饮食养生")
    @RequestMapping(value = "/eat/add", method = RequestMethod.POST)
    public Result addEat(@ModelAttribute YangShengEat yangShengEat) {
        yangShengService.saveYangeShengEat(yangShengEat);
        return success("保存成功");
    }

    @ApiOperation(value = "根据id获取饮食养生")
    @RequestMapping(value = "/eat/get", method = RequestMethod.POST)
    public Result getEat(@RequestParam long id) {
        YangShengEat yangShengEat = yangShengService.getYangShengEatById(id);
        return success("", yangShengEat);
    }

    @ApiOperation(value = "删除饮食养生")
    @RequestMapping(value = "/eat/delete", method = RequestMethod.POST)
    public Result deleteEat(@RequestParam long id) {
        yangShengService.deleteYangShengEat(id);
        return success("删除成功");
    }

    @ApiOperation(value = "更新饮食养生")
    @RequestMapping(value = "/eat/update", method = RequestMethod.POST)
    public Result updateEat(@ModelAttribute YangShengEat yangShengEat) {
        yangShengService.updateYangShengEat(yangShengEat);
        return success("更新成功", yangShengEat);
    }

    @ApiOperation(value = "翻页获取膳食建议列表")
    @RequestMapping(value = "/eat/page", method = RequestMethod.POST)
    public Result pageEat(@RequestParam int pageNo, @RequestParam int pageSize) {
        Page<YangShengEat> result = yangShengService.pageYangShengEat(pageNo, pageSize);
        return success(result);
    }

    @ApiOperation(value = "根据名字获取膳食建议")
    @RequestMapping(value = "/eat/getByName", method = RequestMethod.POST)
    public Result getEatByname(@RequestParam String dietName) {
        YangShengEat result = yangShengService.getYangShengEatByName(dietName);
        return success(result);
    }


    @ApiOperation(value = "保存茶养生")
    @RequestMapping(value = "/tea/add", method = RequestMethod.POST)
    public Result addTea(@ModelAttribute YangShengTea yangShengTea) {
        yangShengService.saveYangeShengTea(yangShengTea);
        return success("保存成功");
    }

    @ApiOperation(value = "根据id获取茶养生")
    @RequestMapping(value = "/tea/get", method = RequestMethod.POST)
    public Result getTea(@RequestParam long id) {
        YangShengTea yangShengTea = yangShengService.getYangShengTeaById(id);
        return success("", yangShengTea);
    }

    @ApiOperation(value = "删除茶养生")
    @RequestMapping(value = "/tea/delete", method = RequestMethod.POST)
    public Result deleteTea(@RequestParam long id) {
        yangShengService.deleteYangShengTea(id);
        return success("删除成功");
    }

    @ApiOperation(value = "更新茶养生")
    @RequestMapping(value = "/tea/update", method = RequestMethod.POST)
    public Result updateTea(@ModelAttribute YangShengTea yangShengTea) {
        yangShengService.updateYangShengTea(yangShengTea);
        return success("更新成功", yangShengTea);
    }

    @ApiOperation(value = "根据名字获取茶建议")
    @RequestMapping(value = "/tea/getByName", method = RequestMethod.POST)
    public Result getTea(@RequestParam String dietName) {
        YangShengTea result = yangShengService.getYangShengTeaByName(dietName);
        return success(result);
    }

    @ApiOperation(value = "翻页获取茶饮建议列表")
    @RequestMapping(value = "/tea/page", method = RequestMethod.POST)
    public Result pageTea(@RequestParam int pageNo, @RequestParam int pageSize) {
        Page<YangShengTea> result = yangShengService.pageYangShengTea(pageNo, pageSize);
        return success(result);
    }


    @ApiOperation(value = "保存药浴养生")
    @RequestMapping(value = "/method/add", method = RequestMethod.POST)
    public Result addMethod(@ModelAttribute YangShengMethod yangShengMethod) {
        yangShengService.saveYangShengMethod(yangShengMethod);
        return success("保存成功");
    }

    @ApiOperation(value = "根据id获取药浴养生")
    @RequestMapping(value = "/method/get", method = RequestMethod.POST)
    public Result getMethod(@RequestParam long id) {
        YangShengMethod yangShengMethod = yangShengService.getYangShengMethodById(id);
        return success("", yangShengMethod);
    }

    @ApiOperation(value = "根据名字获取药浴养生")
    @RequestMapping(value = "/method/getByName", method = RequestMethod.POST)
    public Result getMethod(@RequestParam String name) {
        YangShengMethod yangShengMethod = yangShengService.getYangShengMethodByName(name);
        return success("", yangShengMethod);
    }

    @ApiOperation(value = "删除药浴养生")
    @RequestMapping(value = "/method/delete", method = RequestMethod.POST)
    public Result deleteMethod(@RequestParam long id) {
        yangShengService.deleteYangShengMethod(id);
        return success("删除成功");
    }

    @ApiOperation(value = "更新方法养生")
    @RequestMapping(value = "/method/update", method = RequestMethod.POST)
    public Result updateMethod(@ModelAttribute YangShengMethod yangShengMethod) {
        yangShengService.updateYangShengMethod(yangShengMethod);
        return success("更新成功", yangShengMethod);
    }

    @ApiOperation(value = "翻页获取药浴建议列表")
    @RequestMapping(value = "/method/page", method = RequestMethod.POST)
    public Result pageMethod(@RequestParam int pageNo, @RequestParam int pageSize) {
        Page<YangShengMethod> result = yangShengService.pageYangShengMethod(pageNo, pageSize);
        return success(result);
    }


    @ApiOperation(value = "保存季节养生")
    @RequestMapping(value = "/season/add", method = RequestMethod.POST)
    public Result addSeason(@ModelAttribute YangShengSeaon yangShengSeaon) {
        yangShengService.saveYangShengSeason(yangShengSeaon);
        return success("保存成功");
    }

    @ApiOperation(value = "根据id获取季节养生")
    @RequestMapping(value = "/season/get", method = RequestMethod.POST)
    public Result getSeason(@RequestParam long id) {
        YangShengSeaon yangShengSeaon = yangShengService.getYangShengSeaonById(id);
        return success("", yangShengSeaon);
    }

    @ApiOperation(value = "删除季节养生")
    @RequestMapping(value = "/season/delete", method = RequestMethod.POST)
    public Result deleteSeason(@RequestParam long id) {
        yangShengService.deleteYangShengSeaon(id);
        return success("删除成功");
    }

    @ApiOperation(value = "更新季节养生")
    @RequestMapping(value = "/season/update", method = RequestMethod.POST)
    public Result updateSeason(@ModelAttribute YangShengSeaon yangShengSeaon) {
        yangShengService.updateYangShengSeaon(yangShengSeaon);
        return success("更新成功", yangShengSeaon);
    }

    @ApiOperation(value = "翻页获取季节建议列表")
    @RequestMapping(value = "/season/page", method = RequestMethod.POST)
    public Result pageSeason(@RequestParam int pageNo, @RequestParam int pageSize) {
        Page<YangShengSeaon> result = yangShengService.pageYangShengSeaon(pageNo, pageSize);
        return success(result);
    }


    @ApiOperation(value = "保存运动养生")
    @RequestMapping(value = "/sports/add", method = RequestMethod.POST)
    public Result addSports(@ModelAttribute SportsInputVo yangShengSports) {
        yangShengService.saveYangeShengSports(yangShengSports);
        return success("保存成功");
    }

    @ApiOperation(value = "根据id获取运动养生")
    @RequestMapping(value = "/sports/get", method = RequestMethod.POST)
    public Result getSport(@RequestParam long id) {
        YangShengSports yangShengSports = yangShengService.getYangShengSportsById(id);
        return success("", yangShengSports);
    }

    @ApiOperation(value = "删除运动养生")
    @RequestMapping(value = "/sports/delete", method = RequestMethod.POST)
    public Result deleteSport(@RequestParam long id) {
        yangShengService.deleteYangShengSports(id);
        return success("删除成功");
    }

    @ApiOperation(value = "根据id获取运动养生")
    @RequestMapping(value = "/sports/getByName", method = RequestMethod.POST)
    public Result getSport(@RequestParam String name) {
        YangShengSports yangShengSports = yangShengService.getYangShengSportsByName(name);
        return success("", yangShengSports);
    }

    @ApiOperation(value = "更新运动养生")
    @RequestMapping(value = "/sports/update", method = RequestMethod.POST)
    public Result updateSports(@ModelAttribute SportsInputVo yangShengSports) {
        yangShengService.updateYangShengSports(yangShengSports);
        return success("更新成功", yangShengSports);
    }

    @ApiOperation(value = "翻页获取运动建议列表")
    @RequestMapping(value = "/sports/page", method = RequestMethod.POST)
    public Result pageSports(@RequestParam int pageNo, @RequestParam int pageSize) {
        Page<YangShengSports> result = yangShengService.pageYangShengSports(pageNo, pageSize);
        return success(result);
    }


    @ApiOperation(value = "保存楔子养生")
    @RequestMapping(value = "/xiezi/add", method = RequestMethod.POST)
    public Result addXieZi(@ModelAttribute YangShengXieZi yangShengXieZi) {
        yangShengService.saveYangShengXieZi(yangShengXieZi);
        return success("保存成功");
    }

    @ApiOperation(value = "根据id获取楔子养生")
    @RequestMapping(value = "/xiezi/get", method = RequestMethod.POST)
    public Result getXieZi(@RequestParam long id) {
        YangShengXieZi yangShengXieZi = yangShengService.getYangShengXieZiById(id);
        return success("", yangShengXieZi);
    }

    @ApiOperation(value = "根据id获取楔子养生")
    @RequestMapping(value = "/xiezi/delete", method = RequestMethod.POST)
    public Result deleteXieZi(@RequestParam long id) {
        yangShengService.deleteYangShengXieZi(id);
        return success("删除成功");
    }

    @ApiOperation(value = "更新楔子养生")
    @RequestMapping(value = "/xiezi/update", method = RequestMethod.POST)
    public Result updateXieZi(@ModelAttribute YangShengXieZi yangShengXieZi) {
        yangShengService.updateYangShengXieZi(yangShengXieZi);
        return success("更新成功", yangShengXieZi);
    }

    @ApiOperation(value = "翻页获取运动建议列表")
    @RequestMapping(value = "/xiezi/page", method = RequestMethod.POST)
    public Result pageXieZi(@RequestParam int pageNo, @RequestParam int pageSize) {
        Page<YangShengXieZi> result = yangShengService.pageYangShengXieZi(pageNo, pageSize);
        return success(result);
    }
}
